package com.wc.acwing.思维.多数意见;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

/**
 * @Author congge
 * @Date 2025/2/27 22:35
 * @description
 * https://www.acwing.com/problem/content/description/5527/
 */
public class Main {
    /**
     * 思路：
     * 一个区间内需要一个数 > 一半
     * 只要有 xx 存在就可以覆盖全部
     * 如果没有就需要 xyx 存在才能使得 x覆盖全部
     * 所以说只需要遍历这两个就可以了
     */
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);
    static int N = 100010;
    static int[] a = new int[N];
    static boolean[] st = new boolean[N];
    static int n, m;

    public static void main(String[] args) {
        int T = sc.nextInt();
        while (T-- > 0) {
            n = sc.nextInt();
            Arrays.fill(st, 1, n + 1, false);
            for (int i = 1; i <= n; i++) a[i] = sc.nextInt();
            for (int i = 1; i + 1 <= n; i++) {
                if (a[i] == a[i + 1]) st[a[i]] = true;
            }
            for (int i = 1; i + 2 <= n; i++) {
                if (a[i] == a[i + 2]) st[a[i]] = true;
            }
            boolean vis = true;
            for (int i = 1; i <= n; i++) {
                if (st[i]) {
                    out.print(i + " ");
                    vis = false;
                }
            }
            if (vis) out.println(-1);
            else out.println();
        }
        out.flush();
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    // 是否由下一个
    boolean hasNext() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = br.readLine();
                if (line == null)
                    return false;
                st = new StringTokenizer(line);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return true;
    }
}

